package com.gouwudai.gobbs.dao.impl;

import org.apache.log4j.Logger;

import com.gouwudai.gobbs.dao.ITopicBuyDAO;
import com.gouwudai.gobbs.pojo.TbbsTopicBuy;
import com.litt.core.exception.DBException;

public class TopicBuyDAOImpl extends BaseDAOImpl implements ITopicBuyDAO 
{
	private static final Logger logger = Logger.getLogger(TopicBuyDAOImpl.class);	
	private static final String BUSI_NAME = "金钱帖购买信息";
	
	public void save(TbbsTopicBuy tbbsTopicBuy)
	{    		
		super.saveObject(tbbsTopicBuy);		
	}
	
	public void update(TbbsTopicBuy tbbsTopicBuy)
	{    		
		super.updateObject(tbbsTopicBuy);		
	}	
	
	public TbbsTopicBuy load(Integer id)
	{
		return (TbbsTopicBuy)super.loadObject(TbbsTopicBuy.class, id);
	} 
	
    /**
     * 根据主题ID和用户ID查找
     * @param topicId
     * @param userId
     * @return
     */
	public TbbsTopicBuy loadByTopicUser(Integer topicId,Integer userId)
	{
		StringBuilder listHql = new StringBuilder(100);
		listHql.append("from TbbsTopicBuy obj where obj.topicId=");
		listHql.append(topicId);
		listHql.append(" and obj.userId=");
		listHql.append(userId);
		return (TbbsTopicBuy)super.uniqueResultHql(listHql.toString());
	} 	
    
    public void delete(Integer buyId)
    {
        super.deleteObject(TbbsTopicBuy.class.getName(),"buyId",buyId);
    } 


}
